Skip to main content

General Step to Dockerizing a Project

How to Run a Docker Project

  1. Build the image
docker image build -t zekaryas/projectName .
#docker image build -t{tag or name} name_of_the_image .{where the dockerfile is}
# . means in the current directory
#list images we have
docker image ls
  1. Run the image
docker container run -d -p 80:8080 zekaryas/projectName
# -d = detached: run in the background
# -p = port mapping public_port:container_exposed_port
# list containers and their information {id, state{running, exited},name}
docker ps
  1. Manage the container

Once we have container we can stop/start/restart it using its id

docker stop [container_id]
docker restart [contaier_id]
docker start [container_id]

How to Run a Docker-Compose Project

  1. Build the image(s)
docker-compose up -d --build

# -d = detached background
# --build = build images
docker-compose ps
# Lists containers and their state
  1. Managing docker-compose
docker-compose stop
docker-compose start
docker-compose restart
  1. Remove docker-compose containers and their contents
    • Stops containers and removes containers, networks, volumes, and images created by up.
docker-compose down